<template>
	<view class="container">

		<!-- <view class="wechatapp">
      <view class="header">
        <image class="image" :src="imgurl+listBackdropImg" mode="widthFix"></image>
      </view>
	 
	  
    </view> -->
		<view class="history-top">

			<view class="history-title">
				<text>历史记录</text>
				<view>
					<!-- 进入活动参与活动 -->
				</view>
			</view>
			<view class="history-fh" @click="nextpagefun">
				<image src="/static/images/home8.png"></image>
			</view>

		</view>

		<!-- <view class="on-hx">
		<view class="on-hx-ct">
			
		</view>
	</view> -->

		<view class="content">

			<view class="content-times">
				<view :class="form.timePeriod==1?'view-select-time':''" @click="selecttimes(1)">
					近一个月
				</view>
				<view :class="form.timePeriod==2?'view-select-time':''" @click="selecttimes(2)">
					近三个月
				</view>
				<view :class="form.timePeriod==3?'view-select-time':''" @click="selecttimes(3)">
					近六个月
				</view>

			</view>
			<view class="content-item" v-for="(item,index) in historylist" :key="index">
				<view class="content-infotop">


					<view class="content-iconortitle">
						<image :src="imgurl+item.coverImg"></image>
						<!-- <text>{{item.name}}</text> -->

					</view>
					<view class="content-item-bt">
						<view class="content-item-bt-name">
							{{item.name}}
						</view>
						<view class="content-item-bt-time">
							活动截止日期：{{item.endDate}}
						</view>
						<view class="content-item-bt-time">
							参与活动日期：{{item.joinDate}}
						</view>
						<view class="text-bt">
							<!-- <view class="gopay" @click="goenpay(item)">
						参加活动
					</view> -->
							<view class="goshop" @click="goshop(item.id ,item.type)">
								进入商城
							</view>
						</view>

					</view>

				</view>
				<!-- <view class="content-info">
				<view class="content-info-iconortitle">
					<image src="/static/images/icon_time.png" ></image>
					<text>活动时间</text>
				</view>
				<view class="content-info-time">
					{{item.beginTime}}
				</view>
			</view> -->

			</view>

		</view>

		<!-- 跳 -->
		<!-- <view class="content" v-if="type=='sport'">
		
		<view class="content-item content-itemsport" v-for="(item,index) in historylist" :key="index">
			<view class="content-itemsport-title">
				
			
			<view class="content-itemsport-title-img">
				<image :src="imgurl+item.coverImg" mode="widthFix"></image>
				
			</view>
			<view class="content-item-bt">
				<view class="goshop">
					去商城
				</view>
			</view>
			
			</view>
			<view class="content-infosport">
				<view class="content-info-iconortitle">
				
					<text>{{item.name}}</text>
				</view>
				
			</view>
			
		</view>
		
		
	
		
	</view> -->

		<!-- 跳 -->
		<!-- <view class="content" v-if="type=='walk'">
		
		<view class="content-item content-itemsport" v-for="(item,index) in historylist" :key="index">
			<view class="content-itemsport-title">
				
			
			<view class="content-itemsport-title-img">
				<image :src="imgurl+item.coverImg" mode="widthFix"></image>
				
			</view>
			<view class="content-item-bt">
				
				<view class="goshop">
					去商城
				</view>
				
			</view>
			
			</view>
			<view class="content-infosport">
				<view class="content-info-iconortitle">
					
					<text>{{item.name}}</text>
				</view>
				
			</view>
			
		</view>
		
		
	
		
	</view> -->
		<!-- 跳 -->
		<!-- <view class="content" v-if="type=='study'">
		
		<view class="content-item content-itemsport" v-for="(item,index) in historylist" :key="index">
			<view class="content-itemsport-title">
				
			
			<view class="content-itemsport-title-img">
				<image :src="imgurl+item.coverImg" mode="widthFix"></image>
				
			</view>
			<view class="content-item-bt">
				
				<view class="goshop">
					去商城
				</view>
				
			</view>
			
			</view>
			<view class="content-infosport">
				<view class="content-info-iconortitle">
					
					<text>{{item.name}}</text>
				</view>
				
			</view>
			
		</view>
		
		
	
		
	</view> -->


		<!-- <u-empty text="暂无记录" v-if="historylist.length==0" mode="list" :margin-top="180"></u-empty> -->
		<view class="on-icon" v-if="historylist.length==0">
			<image src="/static/images/no.png" mode=""></image>
		</view>









	</view>
</template>

<script>
	import {
		getHistoryPage,
		getJumpShopUrl
	} from "@/api/index/index";
	import {
		BASE_URL_IMAHE
	} from "../../../utils/https";

	const app = getApp();
	export default {
		data() {
			return {
				form: {
					userRef: "",
					pageNo: 1,
					pageSize: 10,
					v: '',
					timePeriod: 0,
				},
				toall: 0,
				historylist: [],
				imgurl: BASE_URL_IMAHE,
				listBackdropImg: '',
				type: "",
				goshoptrue: false,
			};
		},

		created() {},
		beforeDestroy() {

		},
		onLoad() {
			this.type = uni.getStorageSync("type")
			this.form.v = uni.getStorageSync("v")
			// if(uni.getStorageSync("type")=="chess"){
			this.form.userRef = uni.getStorageSync("userRef")
			// }
			// if(uni.getStorageSync("type")=="sport"){
			// 		  this.form.userRef=uni.getStorageSync("usersportRef")	
			// }
			// if(uni.getStorageSync("type")=="walk"){
			// 		  this.form.userRef=uni.getStorageSync("userwalkRef")	
			// }
			// if(uni.getStorageSync("type")=="study"){

			// 		  this.form.userRef=uni.getStorageSync("userstudyRef")	
			// }
			this.listBackdropImg = uni.getStorageSync('listBackdropImg') ? uni.getStorageSync('listBackdropImg') : ""
			this.getlist()



		},
		onReady() {

		},
		onReachBottom() {
			console.log("到底部 加载更多");
			//请求订单
			if (this.form.pageNo > this.toall) {
				return
			}
			this.getlist()
		},
		methods: {
			selecttimes(index) {
				this.form.timePeriod = index
				this.getlist()
			},
			async goshop(id, type) {
				// window.location.href=url
				let data = {
					joinRecordId: id,
					userRef: uni.getStorageSync("userRef")
				}
				const res = await getJumpShopUrl(JSON.stringify(data))
				if (res.result == 0) {
					this.goshoptrue = true
					// window.location.href = res.jumpShopLink
					if (type == '2') {
						uni.setStorageSync("typejumpShopLink", res.jumpShopLink)
						uni.navigateTo({
							url: "/pages/shop/index"
						})
					} else {
						window.location.href = res.jumpShopLink
					}
				} else {
					uni.showToast({
						title: res.message,
						icon: "none"
					})
				}
			},
			async getlist() {
				// #ifdef MP-WEIXIN
				this.form.type = 2
				// #endif
				const res = await getHistoryPage(JSON.stringify(this.form))
				console.log(res)
				this.toall = Math.ceil(res.page.count / res.page.pageSize)
				this.historylist.push(...res.page.list)
				this.form.pageNo++
				// this.historylist=res.page.list
			},
			nextpagefun() {
				uni.reLaunch({
					url: "/pages/home/index"
				})
			},
			homepagefun() {
				uni.reLaunch({
					url: "/pages/home/index"
				})
			},

		}


	};
</script>

<style lang="scss" scoped>
	.btstyle {
		width: 165rpx;
		background: #0065ff;
		color: white;
	}

	u-checkbox-group::v-deep {
		.u-checkbox__label {
			margin-right: rpx(0);
		}
	}

	.icon-cone {
		margin-right: 10rpx;
	}

	.checkBox_wrapper {
		font-size: rpx(12);
		display: flex;
	}

	.container {
		padding: 0 0rpx;
		font-size: 32rpx;
		background: #fff;
		min-height: 100vh;
		position: relative;
		padding-bottom: 20rpx;
	}

	.back_img {
		position: absolute;
		top: 80rpx;
		right: 0rpx;
		z-index: 1;

		image {
			width: 350rpx;
		}
	}

	.login-test {
		margin-top: rpx(20);

		display: flex;
		justify-content: center;

		.login-item {
			width: rpx(80);
			height: rpx(80);
			text-align: center;
			margin-left: rpx(20);
			margin-right: rpx(20);

			.login-text {
				width: 100%;
				font-size: rpx(15);
				line-height: rpx(35);
			}

			.login-icom {

				// width: rpx(48);
				// height: rpx(48);
				// border-radius: 50%;
				// border: rpx(3) solid black;
				// margin: 0 auto;
				.login-icoms {}
			}
		}
	}

	.wechatapp {
		//border-bottom: 1rpx solid #e3e3e3;
		// margin-bottom: 72rpx;
		text-align: center;
		width: 100%;
		height: 128rpx;
		overflow: hidden;
		position: relative;

		.header {
			width: 100%;
			height: 100%;



			.image {
				width: 100%;
				height: 100%;
			}
		}
	}

	.auth-title {
		color: #585858;
		font-size: 60rpx;
		margin-bottom: 40rpx;
		margin-left: 40rpx;
		margin-top: 80rpx;
	}

	.auth-phonetitle {
		color: #585858;
		font-size: 30rpx;
		margin-bottom: 40rpx;
		margin-left: 40rpx;
		line-height: 60rpx;
		margin-top: 80rpx;
	}

	.auth-subtitle {
		color: #888;
		margin-bottom: 88rpx;
		font-size: 60rpx;

	}

	.login-view {
		width: 100%;
		box-sizing: border-box;
		padding: 0 rpx(20);
	}

	.login-btn-qk {
		font-size: 30rpx;
		text-align: right;
		margin-right: 40rpx;
		margin-top: 40rpx;
	}

	.content-k {
		display: flex;
		justify-content: space-between;
		padding: 60rpx 48rpx 0rpx;
	}

	.history-top {
		margin: 0 auto;
		width: 750rpx;
		height: 380rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;
		background: linear-gradient(179deg, #FFD008, #FFD008);
		box-sizing: border-box;
		padding-left: 78rpx;
		padding-right: 84rpx;

		.history-title {

			font-weight: 500;
			font-size: 55rpx;
			color: #FFFFFF;

			view {
				margin-top: 45rpx;
				font-weight: 500;
				font-size: 26rpx;
				color: #FFFFFF;

			}
		}

		.history-fh {
			image {
				width: 191rpx;
				height: 158rpx;
			}
		}

		.history-home {
			image {
				width: 42rpx;
				height: 44rpx;
			}
		}
	}

	.on-hx {
		width: 749rpx;
		height: 5rpx;
		background-color: #f2f6fe;

		.on-hx-ct {
			width: 100%;
			height: 5rpx;
			background-color: #0065ff;
		}
	}

	.content {
		width: 750rpx;
		position: relative;
		height: auto;
		margin: 19rpx auto 0rpx;
		padding-top: 50rpx;
		top: -50rpx;
		background-color: #ffffff;
		border-radius: 45rpx 45rpx 0 0;

		.content-item {
			width: 642rpx;
			height: auto;
			background: linear-gradient(90deg, #FFFAE6, #FFFAE6);
			border-radius: 20rpx;
			box-sizing: border-box;
			padding: 27rpx 40rpx 27rpx 27rpx;
			margin: 0 auto;
			margin-bottom: 28rpx;

			.content-infotop {
				display: flex;
				justify-content: flex-start;
				position: relative;




				.content-iconortitle {
					display: flex;
					align-items: center;

					image {
						width: 172rpx;
						height: 172rpx;
						border-radius: 28rpx;
					}

					text {
						margin-left: 25rpx;
						font-size: 34rpx;
					}
				}

				.content-item-bt {
					width: 642rpx;
					display: flex;
					flex-direction: column;
					// justify-content:center;
					align-items: flex-start;
					margin-left: 20rpx;

					.content-item-bt-name {
						width: 380rpx;
						font-weight: 600;
						font-size: 28rpx;
						overflow: hidden;
						text-overflow: ellipsis;
						/* 将对象作为弹性伸缩盒子模型显示 */
						display: -webkit-box;
						/* 限制在一个块元素显示的文本的行数 */
						/* -webkit-line-clamp 其实是一个不规范属性，使用了WebKit的CSS扩展属性，该方法适用于WebKit浏览器及移动端；*/
						-webkit-line-clamp: 2;
						/* 设置或检索伸缩盒对象的子元素的排列方式 */
						-webkit-box-orient: vertical;


					}

					.content-item-bt-time {
						margin-top: 18rpx;
						font-weight: 600;
						font-size: 24rpx;
						color: #C1C1C1;
						white-space: nowrap;
					}

					.text-bt {
						display: flex;
						align-items: center;
						justify-content: right;
						width: 100%;
						margin-top: 50rpx;
						// position: absolute;
						// bottom: 0;
						// right: 40rpx;
					}

				}

				.gopay {
					padding: 5rpx 20rpx;
					white-space: normal;
					display: inline;
					background: #FFFFFF;
					border-radius: 18rpx;
					font-weight: 600;
					font-size: 24rpx;
					color: #4E4E4E;
					text-align: center;
					line-height: 48rpx;
					margin-left: 16rpx;
				}

				.goshop {
					padding: 5rpx 20rpx;
					white-space: normal;
					display: inline;
					background: #FFFFFF;
					border-radius: 18rpx;
					font-weight: 600;
					font-size: 24rpx;
					color: #4E4E4E;
					text-align: center;
					line-height: 48rpx;
					margin-left: 16rpx;

				}
			}

			.content-info {
				display: flex;
				justify-content: space-between;
				margin-top: 73rpx;

				.content-info-iconortitle {
					display: flex;
					align-items: center;

					image {
						width: 22rpx;
						height: 22rpx;
					}

					text {
						margin-left: 10rpx;
						font-size: 24rpx;
						color: #8e9aab;
					}
				}

				.content-info-time {
					font-size: 24rpx;
					color: #5e6f88;
				}
			}
		}

		.content-itemsport {
			padding: 0;
			overflow: hidden;
			height: auto;
			border: none;
			border-top-left-radius: 35rpx;
			border-top-right-radius: 35rpx;
			border-bottom-left-radius: 0rpx;
			border-bottom-right-radius: 0rpx;

			.content-itemsport-title {
				width: 100%;
				height: 288rpx;
				overflow: hidden;
				position: relative;

				.content-itemsport-title-img {
					width: 100%;
					height: auto;

					image {
						width: 100%;
						height: auto;
					}
				}
			}

			.content-infosport {
				height: 80rpx;
				font-size: 40rpx;
				text-align: left;
				font-weight: bold;
				line-height: 80rpx;
				padding-left: 20rpx;
				background-color: #f5f5f5;

			}

			.content-item-bt {
				position: absolute;
				width: auto;
				right: 20rpx;
				top: 40rpx;
				display: flex;
				flex-direction: column;
				justify-content: flex-end;
				align-items: flex-end;
			}

			.gopay {
				width: 153rpx;
				height: 37rpx;
				font-size: 24rpx;
				border-radius: 45rpx;
				background-color: #0065ff;
				color: #ffffff;
				text-align: center;
				line-height: 37rpx;
				margin-left: 0rpx;

			}

			.goshop {
				width: 108rpx;
				height: 37rpx;
				font-size: 24rpx;
				border-radius: 45rpx;
				background-color: #0065ff;
				color: #ffffff;
				text-align: center;
				line-height: 37rpx;
				margin-top: 36rpx;
				// margin: 36rpx auto 0rpx;
				margin-left: 0rpx;

			}

			.peple {
				width: auto;
				height: 37rpx;
				line-height: 37rpx;
				margin-top: 36rpx;

				text {
					font-size: 24rpx;
					border-radius: 45rpx;
					background-color: rgba(0, 0, 0, 0.5);
					color: white;
					text-align: center;
					padding: 2rpx 10rpx;
				}
			}

		}

	}

	.on-icon {
		text-align: center;
		padding-top: 212rpx;
	}

	.content-times {
		width: 100%;
		box-sizing: border-box;
		padding: 0rpx 52rpx 44rpx;
		display: flex;
		justify-content: space-between;

		view {
			width: 160rpx;
			height: 53rpx;
			background: #EEEEEE;
			border-radius: 18rpx;
			text-align: center;
			line-height: 53rpx;
			font-weight: 500;
			font-size: 26rpx;
			color: #B2B4B7;
		}

		.view-select-time {
			background: #707070 !important;
		}
	}
</style>